<template>
	<view class="bg" style="background-image: url(../../static/images/beijing.png);width: 100%;height: 1350rpx;">
		<view class="login">
			<form @submit="formSubmit">
				<view class="" style="margin-bottom: 100rpx;margin-top: 160rpx;color: #ffaa00;display: flex;justify-content: center;font-weight: bold;font-size: 39rpx;margin-bottom: 30rpx;">
					<text>高 校 图 书 馆</text>
				</view>
				<!-- <view class="img" style="display: flex;justify-content: center;">
					<image src="../../static/images/beijing.png" style="border-radius: 13px;width: 600upx;height: 120px;"></image>
				</view> -->
				
				<view class="userName" style="margin-top: 100rpx;display: flex;flex-direction: row;">
					<view class="" style="margin-right: 10upx;color: #ffaa00;">
						账号 :
					</view> 
					<view class="">
						<input style="color: #550000;" type="text" name="userName" v-model="userName" placeholder="请输入账号" />
					</view>
				</view>
				
				<view class="userPwd" style="display: flex;flex-direction: row;">
					<view  class="" style="margin-right: 10upx;color: #ff5500;">
						密码 :
					</view>
					<view class="">
						<input type="password" name="userPwd" v-model="userPwd" placeholder="请输入密码" />
					</view>
				</view>
				<!-- <view class="userPwd">
					<picker @change="bindPickerChange" :value="index" :range="array">
						<view class="uni-input">{{array[index]}}</view>
					</picker>
				</view> -->
				<view class="btn">
					<view class="btn2">
						<button type="warn" size="mini" form-type="submit">登录</button>
					</view>
					<view class="">
						<button type="default" size="mini" @tap="register()">注册</button>
					</view>
				</view>
			</form>
				
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userName: 'ancen',
				userPwd: '111',
				array: [],
				index: 0,
			}
		},
		onLoad() {
			
		},
		
		methods: {
			formSubmit() {
				var _this=this
				uni.request({
					url: _this.serverUrl + "renren/usertable/searchUser",
					data: {
						userName: _this.userName,
						userPwd: _this.userPwd
					},
					success(res) {
						if (res.data.code === 0) {
							uni.setStorageSync('usersName',_this.userName)
							uni.setStorageSync('usersId',res.data.userId)
							uni.switchTab({
								url: "../index/index",
							})
							
						} else {
							uni.showToast({
								title: "登陆失败"
							})
						}
					}
				})

			},
		
			register() {
				uni.navigateTo({
					url: "./register"
				})
			}
		}
	}
</script>

<style>
	.bg {
			background-size: 100% 100%;
			background-position: center center;
			overflow: auto;
		}
	.login {
		display: flex;
		flex-direction: column;
		align-items: center;
		margin-top: 130upx;
	}

	.userName,
	.userPwd {
		border: 1px solid #ffffff;
		padding: 20upx;
		border-radius: 16upx;
		width: 600upx;
		margin-top: 30upx;
	}

	.btn {
		display: flex;
		flex-direction: row;
		margin-top: 60upx;
		align-items: center;
		justify-content: space-around
	}

	.btn2 {
		margin-right: 60upx;
	}
</style>
